* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 10px;
    margin: 0;
    overflow: hidden;
    /* 禁止文本选择，改善触摸体验 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* 禁止长按菜单 */
    -webkit-touch-callout: none;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 20px;
    max-width: 800px;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.header h1 {
    color: #667eea;
    font-size: 2.5em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.info {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px;
    border-radius: 10px;
    color: white;
    font-size: 1.2em;
    font-weight: bold;
}

.score-display, .lives-display, .level-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

#gameCanvas {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #1a1a2e;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    touch-action: none; /* 禁止浏览器默认触摸行为 */
}

#canvas {
    display: block;
    background: linear-gradient(to bottom, #0f0c29, #302b63, #24243e);
    max-width: 100%;
    height: auto;
    touch-action: none; /* 禁止浏览器默认触摸行为 */
    cursor: crosshair;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    z-index: 10;
    padding: 30px;
    text-align: center;
}

.screen.hidden {
    display: none;
}

.screen h2 {
    font-size: 3em;
    margin-bottom: 20px;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.instructions {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    backdrop-filter: blur(10px);
}

.instructions p {
    font-size: 1.3em;
    margin-bottom: 15px;
    color: #ffd700;
}

.instructions ul {
    list-style: none;
    text-align: left;
    display: inline-block;
}

.instructions li {
    font-size: 1.1em;
    margin: 10px 0;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
}

.game-btn {
    font-size: 1.5em;
    padding: 15px 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    margin: 20px 0;
}

.game-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.6);
}

.game-btn:active {
    transform: translateY(-1px);
}

.tips {
    margin-top: 20px;
    font-size: 1em;
    color: #aaa;
    font-style: italic;
}

.final-score, .high-score {
    font-size: 1.8em;
    margin: 15px 0;
    color: #ffd700;
}

.final-score span, .high-score span {
    font-size: 1.3em;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

/* 通关画面样式 */
.win-stats {
    width: 100%;
    margin: 20px 0;
}

.win-message {
    font-size: 1.2em;
    color: #ffff00;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.stat-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(5px);
}

.stat-label {
    font-size: 0.9em;
    color: #aaa;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

.footer {
    text-align: center;
    margin-top: 20px;
    color: #667eea;
    font-size: 1em;
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 5px;
        min-height: 100vh;
        min-height: -webkit-fill-available; /* iOS Safari 修复 */
    }

    .game-container {
        padding: 10px;
        border-radius: 15px;
        max-width: 100%;
        width: 100%;
    }

    .header h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }

    .info {
        font-size: 0.85em;
        padding: 10px;
        gap: 10px;
    }

    .screen h2 {
        font-size: 1.8em;
        margin-bottom: 15px;
    }

    .instructions {
        padding: 15px;
        margin: 15px 0;
    }

    .instructions p {
        font-size: 1.1em;
        margin-bottom: 10px;
    }

    .instructions li {
        font-size: 0.85em;
        margin: 8px 0;
        padding: 6px;
    }

    .game-btn {
        font-size: 1.1em;
        padding: 12px 30px;
    }

    .tips {
        font-size: 0.85em;
    }

    .final-score, .high-score {
        font-size: 1.4em;
        margin: 10px 0;
    }

    .footer {
        font-size: 0.85em;
        margin-top: 10px;
    }

    #canvas {
        border-radius: 10px;
    }

    /* 通关画面移动端适配 */
    .win-message {
        font-size: 1em;
    }

    .stats-grid {
        gap: 10px;
    }

    .stat-item {
        padding: 10px;
    }

    .stat-label {
        font-size: 0.8em;
    }

    .stat-value {
        font-size: 1.5em;
    }
}

/* 小屏幕手机适配 */
@media (max-width: 480px) {
    body {
        padding: 3px;
    }

    .game-container {
        padding: 8px;
        border-radius: 10px;
    }

    .header h1 {
        font-size: 1.3em;
    }

    .info {
        font-size: 0.75em;
        padding: 8px;
        gap: 8px;
    }

    .screen h2 {
        font-size: 1.5em;
    }

    .instructions {
        padding: 10px;
    }

    .instructions p {
        font-size: 1em;
    }

    .instructions li {
        font-size: 0.75em;
    }

    .game-btn {
        font-size: 1em;
        padding: 10px 25px;
    }

    /* 通关画面小屏幕适配 */
    .win-message {
        font-size: 0.9em;
    }

    .stat-value {
        font-size: 1.3em;
    }
}

/* 横屏模式优化 */
@media (max-height: 600px) and (orientation: landscape) {
    body {
        padding: 5px;
    }

    .game-container {
        padding: 8px;
        max-height: 100vh;
        overflow-y: auto;
    }

    .header h1 {
        font-size: 1.2em;
        margin-bottom: 5px;
    }

    .info {
        font-size: 0.75em;
        padding: 8px;
    }

    .footer {
        display: none; /* 横屏时隐藏底部文字 */
    }
}

/* 加载动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-container {
    animation: fadeIn 0.5s ease-out;
}

